home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CUCD / Programming / AMOSList / AMOSLIST / text0217.txt < prev    next >
Encoding:
Text File  |  1998-04-01  |  2.8 KB  |  96 lines

  1. > Hello.  It's me again, i wrote the question abouth procedures &
  2. > Gosub's some hours ago, but i just relised that it is less than 20
  3. > days to the big computer party here in Norway called The
  4. > Gathering, and i have to be finnished with the code for the
  5. > diskmag i'am working on before The Gathering starts.
  6. > So PLEEEZ ansver my question FAAAAASSST!!!
  7.  
  8.    Okay.  Let's have a look at the first post... :-)
  9.  
  10.  
  11. > I have a little coding problem that i think most of you are able to
  12. > help me out with quite easily.
  13.  
  14. >     A
  15. >     Procedure A
  16. >        B
  17. >     End Proc
  18. >     Procedure B
  19. >        A
  20. >     End Proc
  21. > This will cause a out or stack error becos it writes the same data
  22. > one time for each loop until you are out of stack space, Right??
  23.  
  24.    Correct.  Calling procedures stores data on the stack, but 
  25.    the End Proc is never reached (nor Pop Proc), so this data is
  26.    never removed from the stack. 
  27.  
  28.  
  29. > But how do you make this work???
  30.  
  31.    Make WHAT work?  What are you trying to do??
  32.  
  33.  
  34. > And will it be better to do it like this??
  35. >     MOVMENT:
  36. >        (some code)
  37. >     Return
  38. >     Procedure A
  39. >        Do
  40. >           (some code)
  41. >           Gosub MOVMENT
  42. >        Loop
  43. >     End Proc 
  44.  
  45.    Again, I'm not sure what you're trying to do.  I can't see why
  46.    you want an infinite loop rather than some conditional loop like
  47.    While SOMETHING or Repeat Until SOMETHING.
  48.  
  49.  
  50. > With this i don't get it to jump out of the procedure and go to
  51. > Movment: and return back into the procedure.  I tryed  Global
  52. > movment  but that did'nt help at all :(
  53.  
  54.    When you call procedure A, it should continually Gosub 
  55.    MOVMENT.  The code in MOVMENT will be executed then
  56.    the Return statement will bring control back to the line after 
  57.    the Gosub (in Procedure A) which is Loop, so this process will
  58.    repeat again... and again... and...
  59.  
  60.  
  61. > The reason i want it to be like one of these examples is that i'm
  62. > gonna have 6 procedures and then it takes up too much space
  63. > and memory to have the code in movment 6 times, when i don't
  64. > need to have it more than one time.
  65.  
  66.    It would help tremendously if you could give us a snip of the
  67.    actual program code or describe exactly what you are trying
  68.    to achieve.
  69.  
  70.    Based on the above, all I can say is try something like this:
  71.  
  72.    Procedure ONE
  73.       DoYourStuff
  74.    End Procedure
  75.    ... same for TWO, THREE, FOUR, FIVE.  All the way up to...
  76.    Procedure SIX
  77.       DoYourStuff
  78.    End Proc
  79.  
  80.    ALLDONE=False
  81.    Repeat
  82.       ProcessSomeStuffHere
  83.       SortOutWhichProcedureToCall
  84.       CallTheProcedureHere (MOVMENT, ONE, TWO, THREE, etc.)
  85.       
  86.       CheckForExitCondition.  If ReadyToExit Set ALLDONE=True
  87.    Until ALLDONE
  88.  
  89.    I really need more info on what you're after as I can't see what
  90.    the problem is. :-)
  91.  
  92.  
  93.                 Garfield Benjamin    e-mail:gbenjam@sosbbs.com
  94.         Website( http://www.sosbbs.com/~gbenjam ): 50% Complete
  95.  
  96.